import {designPage} from "plain-ui-composition";
import {useVisualEditor} from "./useVisualEditor";
import visualData from "./data.json";
import VisualEditor from "../packages/index";
import {visualConfigComponentGroups} from "./visualConfigComponentGroups";

export const App = designPage(() => {

    const url = new URL(window.location.href)
    const preview = !!url.searchParams.get('preview')

    const editor = useVisualEditor({
        data: preview ? JSON.parse(localStorage.getItem('sss')!) : visualData as any,
        components: visualConfigComponentGroups,
        preview,
    })

    return () => (
        <VisualEditor editor={editor}/>
    )
})
